<?php

namespace app\common\model\caijiatong;

use think\Model;

/**
 * 材价库
 */
class Material extends Model
{
    protected $connection = 'database.db_second';//连接配置
    protected $table = 'fa_material';//连接配置
    public function getMaterialList($cateid)
    {
        if (!$cateid) {
            return [];
        }
        $materialinfo = (new Category())->where('id', $cateid)->find();
        $materiallist = [];
        if ($materialinfo['material_ids']) {
            $materialstr = $materialinfo['material_ids'];
            $materiallist = $this->where('id', 'in', $materialstr)->where('status', 'normal')->where('deletetime', null)->field('id,name')->select();
        }
        return $materiallist;
    }

}
